<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text">
    <button>查询</button>
    <ul>
        <li></li>
    </ul>
</body>

</html>
<script>
    // button点击事件
    let btnObj = document.querySelector('button')
    btnObj.onclick = function () {
        // ajax 4 步骤
        const xhr = new XMLHttpRequest
        xhr.onreadystatechange = function () {
            if (xhr.readyState === 4) {
                if (xhr.status === 200) {
                    // 拿到数据后给个变量
                    let res = JSON.parse(xhr.responseText)
                    console.log(res);
                    // 清空ul
                    let ulObj = document.querySelector('ul')
                    ulObj.innerText = ''
                    // 遍历  造li  加到ul中
                    if (!Array.isArray(res.data)) return
                    res.data.forEach(item => {
                        // item就是每一个对象
                        // item {filmId, name, poster ....}
                        let liObj = document.createElement('li')
                        liObj.innerHTML = `${item.context}<br>${item.time}<br>${item.ftime}`
                        ulObj.appendChild(liObj)
                    })
                }
            }
        }
        xhr.open('get', `http://www.kuaidi100.com/query?type=shentong&postid=75840107246047`)
        xhr.send()
    }
</script>